<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>秒杀</title>
    <style>        body {
        font-family: Arial, sans-serif;
    }
    #RBody {
        display: flex;
        flex-direction: column;
        align-items: left;
        margin: 20px auto;
        width: 80%; /* 调整宽度 */
        border: 1px solid #ccc;
        padding: 20px;
        box-sizing: border-box;
    }
    form {
        width: 300px;
        /* 左对齐 */
        float: left;
    }
    label, input, select {
        display: block;
        margin-bottom: 10px;
    }
    label {
        font-weight: bold;
    }
    input[type="submit"] {
        margin-top: 20px;
    }
    </style>
</head>
<body>
<form method="post" action="/kill">
    <h2>周末秒杀</h2>
    <label for="sid">sid:</label>
    <input type="text" id="sid" name="sid">
    <input type="hidden" id="timestamp" name="timestamp">
    <label for="prizeId">prizeId:</label>
    <input type="text" id="prizeId" name="prizeId">
    <input type="submit" value="提交" onclick="submitForm()">
</form>
<form method="post" action="/killList">
    <h2>周末秒杀列表</h2>
    sid:<input type="text" name="sid"><br/>
    <input type="submit" value="查询">
</form>
<form method="post" action="/killTest">
    <h2>周末秒杀预热</h2>
    <input type="submit" value="预热">
</form>
<form method="post" action="/friday/kill">
    <h2>周五秒杀</h2>
    <label for="fsid">sid:</label>
    <input type="text" id="fsid" name="fsid">

    <label for="exchId">exchId:</label>
    <input type="text" id="exchId" name="exchId">
    <input type="hidden" id="fridaytimestamp" name="timestamp">

    <!--        <label for="hour">hour:</label>-->
    <!--        <input type="number" id="hour" name="hour">-->

    <!--        <label for="min">min:</label>-->
    <!--        <input type="number" id="min" name="min">-->

    <!--        <label for="choice">是否提前：</label>-->
    <!--        <select id="choice" name="isAdvance">-->
    <!--            <option value="true">是</option>-->
    <!--            <option value="false">否</option>-->
    <!--        </select>-->

    <!--        <label for="millisecond">millisecond:</label>-->
    <!--        <input type="number" id="millisecond" name="millisecond">-->

    <input type="submit" value="提交" onclick="fridaysubmitForm()">
</form>
<form method="post" action="/friday/list">
    <h2>周五秒杀列表</h2>
    sid:<input type="text" name="sid"><br/>
    <input type="submit" value="查询">
</form>
<form method="post" action="/friday/killTest">
    <h2>周五秒杀预热</h2>
    <input type="submit" value="预热">
</form>
<div id="RBody">
    <h2>返回结果</h2>
    <p>--------------------------</p>
    {{ if .RBody }}{{ .RBody }}{{ end }}
</div>

<script>
    function getCurrentTimestamp() {
        var now = new Date();
        var year = now.getFullYear();
        var month = ("0" + (now.getMonth() + 1)).slice(-2); // 补零
        var day = ("0" + now.getDate()).slice(-2);
        var hours = ("0" + now.getHours()).slice(-2);
        var minutes = ("0" + now.getMinutes()).slice(-2);
        var seconds = ("0" + now.getSeconds()).slice(-2);
        var milliseconds = ("00" + now.getMilliseconds()).slice(-3);

        var fullTimeString = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
        return fullTimeString;
    }
    function submitForm() {
        var submitButton = document.querySelector('input[type="submit"]');
        submitButton.value = '已提交';
        submitButton.disabled = true;
        var timestampInput = document.getElementById('timestamp');
        timestampInput.value = getCurrentTimestamp();
        document.querySelector('form').submit();

    }
    function fridaysubmitForm() {
        var submitButton = document.querySelector('input[type="submit"]');
        submitButton.value = '已提交';submitButton.disabled = true;
        var timestampInput = document.getElementById('fridaytimestamp');
        timestampInput.value = getCurrentTimestamp();
        document.querySelector('form').submit();
}
</script>
</body>
</html>